Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring lazy initialization for model metadata #652

Merged
merged 1 commit into from Sep 21, 2012
Merged

Refactoring lazy initialization for model metadata #652

merged 1 commit into from Sep 21, 2012

Conversation

jails
Copy link
Contributor

@jails jails commented Sep 21, 2012

Hi nate, I saw you have already implemented the lazy initialization for model metadata, sorry for the delay.
In this PR you will find my acutal "state" for this subject (from your implementation).
Using $_meta in closures is imo not safe since $_meta may contains in the same time initialized and not yet initialized metadata. Since the initialization is done lazily the order of initialization may produce different results. I also updated the autoConfig and added some tests.

Example of use :

Posts::config(array(
    'initializers' => array(
        'source' => function($self) {
            return 'custom_' . Inflector::underscore($self::meta('name'));
        },
        'name' => function($self) {
            return Inflector::singularize(basename(str_replace('\\', '/', $self)));
        }
    )
));

@nateabele
Copy link
Member

Nice.

nateabele added a commit that referenced this pull request Sep 21, 2012
Refactoring lazy initialization for model metadata
@nateabele nateabele merged commit f2b556e into UnionOfRAD:data Sep 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants